from tkinter import *
import time
from tkinter import messagebox


'''功能：通过点击不同的button,在标签框上输出不同的结果'''

windows = Tk()
windows.title('my windows')
windows.geometry('200x200')

# var1=StringVar()
# l=Label(windows,font=12,width=20,height=2,bg='yellow',text='')   #text最开始定义为空
# l.pack()
# def msg():
#     l.config(text='your select:' + var1.get())              #l.config可以获取l对象的所有配置，重新定义text的值

# def msg1():
#     messagebox.showinfo('提示:','你选择的是%s'%var1.get())
# r1 = Radiobutton(windows,text='Option A',font=12,height=2,variable=var1,value='A',command=msg)        #当点击button的时候，将value的值传给var1变量 
# r1.pack()
# r2 = Radiobutton(windows,text='Option B',font=12,height=2,variable=var1,value='B',command=msg)        #当点击button的时候，将value的值传给var1变量 
# r2.pack()
# b = Button(windows,text='确定',command=msg1)
# b.pack()

v1 = StringVar()
v2 = StringVar()

def log():
    if v1.get() == '1':
        messagebox.showinfo('提示','你选择了看电影')
    if v2.get() == '1':
        messagebox.showinfo('提示','你选择了听歌')
    if v1.get() == '0' and v2.get() == '0':
        messagebox.showinfo('提示','好样的')


r1 = Checkbutton(windows,text='看电影', variable=v1, onvalue=1, offvalue=0)   # 若选中此框则为1,没有选中则为0
r1.pack()
r2 = Checkbutton(windows,text='听歌', variable=v2, onvalue=1, offvalue=0)   # 若选中此框则为1,没有选中则为0
r2.pack()

b1 = Button(windows,text='active',command=log).pack()

windows.mainloop()